#include <stdio.h>
#include <stdlib.h>
#define MAX 2

// 其实在结构体加一个 size 变量就挺省事的，我写了坨很牛的屎
typedef struct {
    int arr[MAX+1];
    int front;
    int rear;
    // int size;  补一下，无济于事。。。
} Queue;

Queue *initqueue(){
    Queue *queue = (Queue*)malloc(sizeof(Queue));
    queue->front = 0;
    queue->rear = 0;
    return queue;
}

int forward(int point){
    return (point+1)%(MAX+1);
}

void enqueue(Queue *queue, int value){
    if(forward(queue->rear) != queue->front){
        queue->arr[queue->rear] = value;
        queue->rear = forward(queue->rear);
    }else{
        printf("Queue is full!\n");
    }
}

int dequeue(Queue *queue){
    if(queue->front != queue->rear){
        int n = queue->arr[queue->front];
        queue->front = forward(queue->front);
        return n;
    }else{
        printf("Queue is empty!\n");
    }
}

int main(){ // 别说奥，代码运行起来还挺好用( •̀ ω •́ )y
    Queue *queue = initqueue();

    enqueue(queue,12);
    enqueue(queue,33);
    enqueue(queue,37);
    
    printf("%d\n",dequeue(queue));
    printf("%d\n",dequeue(queue));
    printf("%d\n",dequeue(queue));

    return 0;
}